home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / dnalib59.arj / ASK.BAS < prev    next >
BASIC Source File  |  1993-12-29  |  7KB  |  221 lines

  1. DECLARE SUB Popwind(Title$,Toprow%,Leftcolumn%,Bottomrow%,Rightcolumn%,Attr%, Shadow%, Border%)
  2. DECLARE SUB SaveScreen(ScreenID$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Shadow%)
  3. DECLARE SUB RestoreScreen(ScreenID$,TopRow%,LeftColumn%)
  4. DECLARE SUB CalcByte(Attr%,LowByte%,HiByte%)
  5. DECLARE SUB Clicked(Rgt%,Lft%,Row%,Col%)
  6. DECLARE SUB HideCursor()
  7. DECLARE SUB ShowCursor()
  8. DECLARE FUNCTION LeftButtonReleased%()
  9.  
  10. SUB ASK(Text$,Mouse%,Rtrn%,Location%,Button%,Push%,Attr%,Shadow%,Border%) PUBLIC
  11.  
  12. CalcByte Attr%,FGround%,BGround%
  13.  
  14. IF Mouse% THEN HideCursor
  15.  
  16. X% = LEN (Text$) AND 1
  17.  
  18. IF X% = 0 THEN                   'see if the string is odd or even
  19.   Prompt$ = Text$
  20. ELSE
  21.   Prompt$ = Text$ + CHR$(63)     'if it's odd add a question mark
  22. END IF
  23.  
  24. IF LEN (Prompt$) <= 28 THEN      'only size the box if the string
  25.   Size% = 32                     'is less than 28 characters
  26. ELSEIF LEN (Prompt$) >= 28 THEN
  27.   Size% = LEN (Prompt$) + 4      'make the box fit the string
  28. END IF
  29.  
  30. IF Rtrn% = 0 THEN                'set up the defaults
  31.   A$ = "No"                      'and somthing to Test against
  32.   Test% = 1
  33. ELSEIF Rtrn% = 1 THEN
  34.   A$ = "Ok"
  35.   Test% = 0
  36. END IF
  37.  
  38. '┌─────────────────────────────────────────────────────────────────────┐
  39. '│  The following block of code places the window on screen with a     │░░
  40. '│  call to POPWIND, prints the buttons and allows the user to move    │░░
  41. '│  between choices using the left and right arrow keys, by either     │░░
  42. '│  INCRementing or DECRementing the variable Pointer%.                │░░
  43. '└─────────────────────────────────────────────────────────────────────┘░░
  44. '  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  45.  
  46. SaveScreen AskScreen$,Location%, 40 - (Size% / 2), Location% + 5, 40 + (Size% / 2) - 1, Shadow%
  47.  
  48. Popwind Title$,Location%, 40 - (Size% / 2), Location% + 5, 40 + (Size% / 2) - 1, Attr%, Shadow%, Border%
  49.  
  50. Pointer% = 1
  51.  
  52. LOCATE Location% + 1, 40 - LEN (Prompt$) / 2,0
  53. COLOR Fground%, Bground%
  54. PRINT Prompt$;
  55.  
  56. PrintRoutine:
  57. DO
  58.  
  59.  Row% = Location% + 2
  60.  Col% = 26
  61.  COLOR Button%, Bground%
  62.  LOCATE Row%, Col%,0
  63.  
  64.  SELECT CASE Pointer%
  65.  
  66.         CASE 1
  67.           PRINT "╔════════╗ ┌────┐ ┌────────┐";
  68.           LOCATE Row% + 1, Col%,0
  69.           PRINT "║ <────┘ ║ │ " + A$ + " │ │ CANCEL │";
  70.           LOCATE Row% + 2, Col%,0
  71.           PRINT "╚════════╝ └────┘ └────────┘";
  72.  
  73.         CASE 2
  74.           PRINT "┌────────┐ ╔════╗ ┌────────┐";
  75.           LOCATE Row% + 1, Col%,0
  76.           PRINT "│ <────┘ │ ║ " + A$ + " ║ │ CANCEL │";
  77.           LOCATE Row% + 2, Col%,0
  78.           PRINT "└────────┘ ╚════╝ └────────┘";
  79.  
  80.         CASE 3
  81.           PRINT "┌────────┐ ┌────┐ ╔════════╗";
  82.           LOCATE Row% + 1, Col%,0
  83.           PRINT "│ <────┘ │ │ " + A$ + " │ ║ CANCEL ║";
  84.           LOCATE Row% + 2, Col%,0
  85.           PRINT "└────────┘ └────┘ ╚════════╝";
  86.  
  87.  END SELECT
  88.  
  89. WHILE NOT INSTAT
  90.   IF Mouse% THEN
  91.     ShowCursor
  92.     Rgt% = 0:Lft% = 0
  93.     Clicked Rgt%,Lft%,MRow%,MCol%
  94.     IF Lft% AND MRow% >= Row% AND MRow% <= Row% + 2 THEN
  95.       IF LeftButtonReleased% THEN
  96.         Chose% = 13
  97.         HideCursor
  98.         GOTO KeyBoardRoutine
  99.       ELSE
  100.         SELECT CASE MCol%
  101.           CASE Col% TO Col% + 9
  102.             Pointer% = 1
  103.             HideCursor
  104.             GOTO PrintRoutine
  105.           CASE Col% + 11 TO Col% + 16
  106.             Pointer% = 2
  107.             HideCursor
  108.             GOTO PrintRoutine
  109.           CASE Col% + 18 TO Col% + 27
  110.             Pointer% = 3
  111.             HideCursor
  112.             GOTO PrintRoutine
  113.         END SELECT
  114.       END IF
  115.     ELSEIF Rgt% THEN
  116.       HideCursor
  117.       Chose% = 27
  118.       GOTO KeyBoardRoutine
  119.     END IF
  120.   END IF
  121. WEND
  122. Ky$ = INKEY$
  123.  
  124.  
  125. IF LEN(Ky$) = 1 THEN
  126.   Chose% = ASC(Ky$)
  127. ELSE
  128.   Chose% = -ASC(RIGHT$(Ky$,1))
  129. END IF
  130.  
  131. '┌─────────────────────────────────────────────────────────────────────┐
  132. '│  The second SELECT CASE uses the variable Pointer% to decide which  │░░
  133. '│  Button to hilite after a selection has been made by hitting the    │░░
  134. '│  Enter key, if an arrow key is pressed then Pointer% is INCR or     │░░
  135. '│  DECR and LOOPs to the top of the loop and the Buttons are PRINTed  │░░
  136. '│  in there new arrangement, and waits for a key stroke.              │░░
  137. '└─────────────────────────────────────────────────────────────────────┘░░
  138. '  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  139.  
  140. KeyBoardRoutine:
  141.  
  142. IF Mouse% THEN HideCursor
  143.  
  144. SELECT CASE Chose%
  145.  
  146.         CASE 13   'enter key
  147.           COLOR Push%, Bground%
  148.  
  149.           SELECT CASE Pointer%
  150.  
  151.                 CASE 1
  152.                   LOCATE Row%, Col%,0
  153.                   PRINT "╔════════╗";
  154.                   LOCATE Row% + 1, Col%,0
  155.                   PRINT "║ <────┘ ║";
  156.                   LOCATE Row% + 2, Col%,0
  157.                   PRINT "╚════════╝";
  158.  
  159.                 CASE 2
  160.                   LOCATE Row%, Col% + 11,0
  161.                   PRINT "╔════╗";
  162.                   LOCATE Row% + 1, Col% + 11,0
  163.                   PRINT "║ " + A$ + " ║";
  164.                   LOCATE Row% + 2, Col% + 11,0
  165.                   PRINT "╚════╝";
  166.                   Rtrn% = Test%
  167.  
  168.                 CASE 3
  169.                   LOCATE Row%, Col% + 18,0
  170.                   PRINT "╔════════╗";
  171.                   LOCATE Row% + 1, Col% + 18,0
  172.                   PRINT "║ CANCEL ║";
  173.                   LOCATE Row% + 2, Col% + 18,0
  174.                   PRINT "╚════════╝";
  175.                   Rtrn% = 2
  176.  
  177.                 END SELECT
  178.                  SelectionMade% = 1
  179.  
  180.         CASE 27   'Esc key
  181.           COLOR Button%, Bground%
  182.           LOCATE Row%, Col%,0
  183.           PRINT "┌────────┐ ┌────┐";
  184.           LOCATE Row% + 1, Col%,0
  185.           PRINT "│ <────┘ │ │ " + A$ + " │";
  186.           LOCATE Row% + 2, Col%,0
  187.           PRINT "└────────┘ └────┘";
  188.           COLOR Push%, Bground%
  189.           LOCATE Row%, Col% + 18,0
  190.           PRINT "╔════════╗";
  191.           LOCATE Row% + 1, Col% + 18,0
  192.           PRINT "║ CANCEL ║";
  193.           LOCATE Row% + 2, Col% + 18,0
  194.           PRINT "╚════════╝";
  195.           Rtrn% = 2
  196.           SelectionMade% = 1
  197.  
  198.         CASE -75 'left arrow
  199.           IF Pointer% > 1 THEN
  200.             DECR Pointer%
  201.           ELSE
  202.             Pointer% = 3
  203.           END IF
  204.  
  205.         CASE -77 'right arrow
  206.           IF Pointer% < 3 THEN
  207.             INCR Pointer%
  208.           ELSE
  209.             Pointer% = 1
  210.           END IF
  211.  
  212.         CASE ELSE
  213.           BEEP
  214.  
  215. END SELECT
  216.  
  217. LOOP UNTIL SelectionMade% = 1
  218. DELAY .5
  219. RestoreScreen AskScreen$,Location%, 40 - (Size% / 2)
  220. END SUB
  221.